package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.impl.DesignerDaoImpl;
import com.ysd.dao.impl.NewscategoryDaoImpl;
import com.ysd.dao.impl.NewsdetailsDaoImpl;
import com.ysd.entity.Newscategory;
import com.ysd.entity.Newsdetails;

public class NewsServlaet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 调用实现类
		// 资讯分类
		NewscategoryDaoImpl newscategoryDao = new NewscategoryDaoImpl();
		List<Newscategory> newscategoryList = newscategoryDao.getNewscategory();
		request.setAttribute("newscategoryList", newscategoryList);
		
		int nid=Integer.parseInt(request.getParameter("newsCategoryId"));
		NewsdetailsDaoImpl newsdetailsDao= new NewsdetailsDaoImpl();
		List<Newsdetails> newsdetails= newsdetailsDao.getNewsdetails(nid);
		request.setAttribute("newsdetails", newsdetails);
		request.getRequestDispatcher("article_list.jsp").forward(request, response);//转发
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
